package internal

func (r *RouterMakeup) make(ginProperty properties_gin.GinProperty) {
	contextPathGroup := r.makeContextPathGroup(ginProperty)
	privateGroup := contextPathGroup.Group("")
	publicGroup := contextPathGroup.Group("")
	privateGroup.Use(authorizeGroupHandlers...)
	privateGroup.Use(r.preHandlerChain.DoChain())

	// --------$%replenish gen code at down place: Make%$--------------
	{{ range $elem := .ModuleNameSet.Iterator.C }}
	   {{ $elemUp := FirstLetterUp $elem}}
	r.make{{$elemUp}}PathGroup(privateGroup, ginProperty)
	{{ end }}
}
{{ range $elem := .ModuleNameSet.Iterator.C }}
  {{ $elemUp := FirstLetterUp $elem}}
// {{$elem}}
func (r *RouterMakeup) make{{$elemUp}}PathGroup(contextPathGroup *gin.RouterGroup, ginProperty *properties_gin.GinProperty) {
	{{$elem}}PathGroup := r.createRouterGroup("", "{{$elem}}", contextPathGroup)
	{{ range $codeGeneratorResp := $.CodeGeneratorResps }}
      {{ if eq $elem $codeGeneratorResp.TableDetailResp.ModuleName }}
	r.make{{$elemUp}}{{$codeGeneratorResp.TableDetailResp.StructName}}PathGroup({{$elem}}PathGroup, ginProperty)
	  {{end}}
	{{end}}
}
{{ range $codeGeneratorResp := $.CodeGeneratorResps }}
  {{ if eq $elem $codeGeneratorResp.TableDetailResp.ModuleName }}
  {{$shortStructName:=$codeGeneratorResp.TableDetailResp.StructName}}
// {{FirstLetterLower $codeGeneratorResp.TableDetailResp.PackageName}}
func (r *RouterMakeup) make{{$elemUp}}{{$shortStructName}}PathGroup({{$elem}}PathGroup *gin.RouterGroup, ginProperty *properties_gin.GinProperty) {
    {{$ctrlInst := FirstLetterLower $shortStructName}}
	{{$ctrlInst}}CtrlInst := http.MainCtrlGroupInst.{{$elemUp}}CtrlGroupInst.{{$shortStructName}}CtrlInst
	extraHandlers := []gin.HandlerFunc{loginfo.DoLogOperInfo(), {{$ctrlInst}}CtrlInst.InitCtrl({{$ctrlInst}}CtrlInst)}
	{{$ctrlInst}}PathGroup := r.createRouterGroup("/{{$ctrlInst}}", "/{{$ctrlInst}}", {{$elem}}PathGroup)

	{{$ctrlInst}}PathGroup.GET("/list", r.checkPermission("{{$elem}}:{{$ctrlInst}}:list"), {{$ctrlInst}}CtrlInst.Get{{$shortStructName}}Page)
	{{$ctrlInst}}PathGroup.POST("", r.mergeHandlers(extraHandlers, r.checkPermission("{{$elem}}:{{$ctrlInst}}:add"), {{$ctrlInst}}CtrlInst.Add{{$shortStructName}})...)
	{{$ctrlInst}}PathGroup.PUT("", r.mergeHandlers(extraHandlers, r.checkPermission("{{$elem}}:{{$ctrlInst}}:edit"), {{$ctrlInst}}CtrlInst.Update{{$shortStructName}}ById)...)
	{{$ctrlInst}}PathGroup.DELETE("/:ids", r.mergeHandlers(extraHandlers, r.checkPermission("{{$elem}}:{{$ctrlInst}}:remove"), {{$ctrlInst}}CtrlInst.DeleteByIds)...)
	{{$ctrlInst}}PathGroup.GET("/:id", r.checkPermission("{{$elem}}:{{$ctrlInst}}:query"), {{$ctrlInst}}CtrlInst.Get{{$shortStructName}}ById)
	{{if ContainField  $codeGeneratorResp.TableDetailResp.Columns "status"}}
	{{$ctrlInst}}PathGroup.PUT("/changeStatus", r.mergeHandlers(extraHandlers, r.checkPermission("{{$elem}}:{{$ctrlInst}}:edit"), {{$ctrlInst}}CtrlInst.Update{{$shortStructName}}Status)...)
    {{end}}
}
  {{end}}
{{end}}
{{end}}